package net.fdukedom.chart.constraints;

import net.fdukedom.chart.Function2D;

/**
 * 
 * @author Fedor Tsarev
 *
 */
public abstract class Constraint {
	protected final Function2D function;
	
	public Constraint(Function2D function) {
		this.function = function;
	}
	
	/**
	 * 
	 * Rasterizes the constraint. Returns <code>boolean[][]</code>, [i][j]-element of
	 * which corresponds to the square 
	 * <i>[minX + i * dx, minX + (i + 1) * dx] X [minY + i * dy, minY + (i + 1) * dy]</i>,
	 * where <i> dx = (maxX - minX) / width </i>, <i> dy = (maxY - minY) / height </i>.
	 * This element is <code>true</code> if more than half of this square satisfies the
	 * constraint. 
 	 * 
	 * @param width number of pixels in horizontal direction
	 * @param height number of pixels in vertical direction
	 * @param minX minimal X-coordinate of point in the area to be rasterized
	 * @param minY minimal Y-coordinate of point in the area to be rasterized
	 * @param maxX maximal X-coordinate of point in the area to be rasterized
	 * @param maxY maximal Y-coordinate of point in the area to be rasterized
	 * @return array which contains rasterization of the constraint
	 */
	public abstract boolean[][] getContainsMap(int width, int height, double minX, double minY, double maxX, double maxY);
	
}
